<?php

    class Sitem extends CI_Model{

        function __construct(){
            parent::__construct();
        }

        function read($page='',$sub='',$upsub=''){
            
            switch ($page){
                case 'home': $page= 'novosti'; break;
            }

            $this->db->order_by("datetime", "desc"); 
            $row = $this->db->get_where('text',array('page'=>$page,'lang'=>$this->lang_ses->getLang()))->result_array();

            /*
            * If no data
            * create new object with message
            */ 

            if(count($row)==0){   

                $instance = new newRow($this->lang->line('nodata'));
                $row = $instance;     

            }

            return $row; 
        }
        
        function readAll($page){
             $row = $this->db->get_where('text',array('page'=>$page,'lang'=>$this->lang_ses->getLang()))->result_array();
             return $row;
        }

        function getTitle($page = 'home', $sub = '', $upsub = ''){
            
            switch($page){
                case 'home': return 'Dobrodošli'; break;
                case 'onama': return 'O nama'; break;
                case 'usloviputovanja': return 'Opšti uslovi putovanja'; break;
                case 'posao': return 'Posao'; break;
                case 'faq': return 'FAQ'; break;
                case 'redplovidbe': return 'Red plovidbe'; break;
                case 'cjenovnik': return 'Cjenovnik'; break;
                case 'spedicija': return 'Špedicija'; break;
                case 'kontakt': return 'Kontakt'; break;
                case 'promocije': return 'Promocije'; break;
                case 'novosti': return 'Novosti'; break;
            
            }
            
        }

    }

    class newRow
    {
        public $title = '';
        public $text = '';

        function __construct($txt){
            $this->title = $txt;
        }
    }



?>
